package entity;

import java.util.Date;

public class Ticket {
    private String ticketId;
    private Schedule schedule;
    private String seatRow;
    private int seatNumber;
    private double price;
    private String status; // "未售出"、"已售出"、"已退票"
    private String electronicTicketId; // 电子票号

    public Ticket() {
    }

    public Ticket(String ticketId, Schedule schedule, String seatRow, int seatNumber, double price) {
        this.ticketId = ticketId;
        this.schedule = schedule;
        this.seatRow = seatRow;
        this.seatNumber = seatNumber;
        this.price = price;
        this.status = "未售出";
        this.electronicTicketId = generateElectronicTicketId();
    }

    // 生成电子票号（简单实现，实际项目中可使用更复杂的算法或库）
    private String generateElectronicTicketId() {
        return "ET" + System.currentTimeMillis() + ticketId.hashCode();
    }

    // Getter 和 Setter 方法
    public String getTicketId() {
        return ticketId;
    }

    public void setTicketId(String ticketId) {
        this.ticketId = ticketId;
    }

    public Schedule getSchedule() {
        return schedule;
    }

    public void setSchedule(Schedule schedule) {
        this.schedule = schedule;
    }

    public String getSeatRow() {
        return seatRow;
    }

    public void setSeatRow(String seatRow) {
        this.seatRow = seatRow;
    }

    public int getSeatNumber() {
        return seatNumber;
    }

    public void setSeatNumber(int seatNumber) {
        this.seatNumber = seatNumber;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getElectronicTicketId() {
        return electronicTicketId;
    }

    public void setElectronicTicketId(String electronicTicketId) {
        this.electronicTicketId = electronicTicketId;
    }

    @Override
    public String toString() {
        return "Ticket{" +
                "ticketId='" + ticketId + '\'' +
                ", schedule=" + schedule +
                ", seatRow='" + seatRow + '\'' +
                ", seatNumber=" + seatNumber +
                ", price=" + price +
                ", status='" + status + '\'' +
                ", electronicTicketId='" + electronicTicketId + '\'' +
                '}';
    }
}